package com.cykj.controller;

import com.cykj.dto.ResponseDTO;
import com.cykj.service.IAdminService;
import com.cykj.utils.JwtUtil;
import com.cykj.vo.AdminVO;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * @author 王宇
 * @CreateTime: 2025-07-28  09:20
 * @BelongsProject: jd_seckill
 * @BelongsPackage: com.cykj.controller
 * @description 管理员管理
 */
@RestController
@RequestMapping("/jd/sys/admin")
public class AdminController {
    @Autowired
    private IAdminService adminService;

    @PostMapping("/login")
    public ResponseDTO login(@RequestBody AdminVO adminVO) {
        return adminService.login(adminVO);
    }

    @GetMapping("/getInfoToken")
    public ResponseDTO getInfoToken(@RequestParam String token) {
        Claims claims = JwtUtil.parseJWT(token);
        return ResponseDTO.success("解析token成功", claims);
    }

    @PostMapping("/logout")
    public ResponseDTO logout() {
        return ResponseDTO.success("登出成功");
    }
}
